import { login, loginCodeLogin } from '@/api/user'
const state = {
  userInfo: '',
  redirect: '/'
}
const mutations = {
  setUserInfo (state, value) {
    state.userInfo = value
  },
  // 退出 登陆处理
  logout (state) {
    state.userInfo = ''
  },
  // 修改回跳地址
  setRedirect (state, value) {
    state.redirect = value
  }
}
const actions = {
  // 用户名登陆
  async userAccountLogin ({ commit }, value) {
    const res = await login(value)
    commit('setUserInfo', res.result)
    console.log(res)
  },
  // 手机登陆
  async userMobileLogin ({ commit }, value) {
    const res = await loginCodeLogin(value)
    commit('setUserInfo', res.result)
    console.log(res)
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
